import { http } from '@/utils/http';
import type { ShareBook } from './index.d';

export { ShareBook };

/** 获取学校是否开通借阅功能 */
export const getSchoolHasSharedBookstore = (data: ShareBook.HasSharedBookstoreParams) => {
	return http({
		url: `/api/cloudbook/is_open_reader`,
		method: 'POST',
		data,
	});
};

/** 获取学校是否开通借阅功能 */
export const getRecordsList = (data: ShareBook.RecordsListParams) => {
	return http<ShareBook.RecordsData>({
		url: `/api/cloudbook/borrow_record`,
		method: 'POST',
		data,
	});
};

/** 大家都在读 */
export const getAllReadList = (data: ShareBook.AllReadListParams) => {
	return http<ShareBook.AllReadData>({
		url: `/api/cloudbook/book_ranking`,
		method: 'POST',
		data,
	});
};

/** 图书查询 */
export const getSearchRecordsList = (data: ShareBook.SearchListParams) => {
	return http<ShareBook.SearchReadData>({
		url: `/api/cloudbook/query_book`,
		method: 'POST',
		data,
	});
};

/** 获取学生借读证数据 */
export const getCardInfoApi = (data: ShareBook.CardInfoParams) => {
	return http<ShareBook.CardData>({
		url: `/api/cloudbook/get_student_reader_code`,
		method: 'POST',
		data,
	});
};

/** 学生解除绑定借读证 */
export const unbindCardInfoApi = (data: ShareBook.UnbindParams) => {
	return http({
		url: `/api/cloudbook/unbind_reader_code`,
		method: 'POST',
		data,
	});
};
/** 学生挂失借读证 */
export const lostCardInfoApi = (data: ShareBook.LostParams) => {
	return http({
		url: `/api/cloudbook/loss_reader_code`,
		method: 'POST',
		data,
	});
};

/** 学生绑定借读证 */
export const bindCardInfoApi = (data: ShareBook.BindParams) => {
	return http({
		url: `/api/cloudbook/bind_reader_code`,
		method: 'POST',
		data,
	});
};
/** 学生绑定借读证验证阅读卡 */
export const validCardInfoApi = (data: ShareBook.ValidParams) => {
	return http<ShareBook.CardData>({
		url: `/api/cloudbook/valid_reader_code`,
		method: 'POST',
		data,
	});
};
/** 添加学生借读积分 */
export const getIntegralApi = (data: ShareBook.IntegralParams) => {
	return http({
		url: `/api/cloudbook/add_integral`,
		method: 'POST',
		data,
	});
};
